﻿<UserControl
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:p="clr-namespace:Photon.Samples.Commands"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:Input="clr-namespace:Photon.Windows.Input;assembly=Photon.Corelib.Silverlight" x:Class="Photon.Samples.Commands.MainPage"
    mc:Ignorable="d"
    d:DesignHeight="488" d:DesignWidth="536">
    <UserControl.Resources>
        <Input:FeedbackPresenter x:Key="FeedbackPresenter" CanUpdateIsEnabled="True" />
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White" >
    	<sdk:TabControl>
    		<sdk:TabItem x:Name="Sample1Tab" Header="Sample1">
    			<StackPanel x:Name="StackPanel" Input:Invoke.Target="{Binding SelectedItem, ElementName=PeopleList}">
    				<ListBox x:Name="PeopleList" Height="200" ItemsSource="{Binding People}" Margin="3" />
    				<Grid DataContext="{Binding SelectedItem, ElementName=PeopleList}">
    					<Grid.RowDefinitions>
    						<RowDefinition Height="Auto"/>
    						<RowDefinition Height="Auto"/>
    						<RowDefinition Height="Auto"/>
    					</Grid.RowDefinitions>
    					<Grid.ColumnDefinitions>
    						<ColumnDefinition Width="Auto"/>
    						<ColumnDefinition/>
    					</Grid.ColumnDefinitions>
    					<sdk:Label Content="Firstname:" HorizontalAlignment="Left" Margin="6"/>
    					<TextBox x:Name="FirstNameInput" Text="{Binding Firstname, Mode=OneWay}" Grid.Column="1" Margin="3" />
    					<sdk:Label Grid.Row="1" Content="Surname:" Margin="6"/>
    					<TextBox x:Name="SurnameInput" Text="{Binding Surname, Mode=OneWay}" Grid.Column="1" Grid.Row="1" Margin="3" />
    					<sdk:Label Grid.Row="2" Content="Salary:" Margin="6"/>
    					<TextBox x:Name="SalaryInput" Text="{Binding Salary, Mode=OneWay}" Grid.Column="1" Grid.Row="2" Margin="3" />
    				</Grid>
    				<Button x:Name="ApplyChangesButton" Content="Apply Changes" Margin="6">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<Input:InvokeMethod MethodName="UpdateName(string,string)" FeedbackPresenter="{StaticResource FeedbackPresenter}" >
    								<Input:InvokeMethod.Arguments>
    									<Input:Argument Value="{Binding Text, ElementName=FirstNameInput}" />
    									<Input:Argument Value="{Binding Text, ElementName=SurnameInput}" />
    								</Input:InvokeMethod.Arguments>
    							</Input:InvokeMethod>
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</Button>
    				<Button x:Name="UpdateSalary" Margin="6">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<Input:InvokeMethod MethodName="UpdateSalary" FeedbackPresenter="{StaticResource FeedbackPresenter}" >
    								<Input:InvokeMethod.Arguments>
    									<Input:Argument Value="{Binding Text, ElementName=SalaryInput}" />                                
    								</Input:InvokeMethod.Arguments>
    							</Input:InvokeMethod>
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</Button>
    				<Button x:Name="UndoChanges" Margin="6" Input:Invoke.Target="{Binding DataContext, ElementName=StackPanel}">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<Input:InvokeMethod MethodName="UndoChanges(Person, string, string)" FeedbackPresenter="{StaticResource FeedbackPresenter}" >
    								<Input:InvokeMethod.Arguments>
    									<Input:Argument Value="{Binding SelectedItem, ElementName=PeopleList}" />
    									<Input:Argument Value="{Binding Text, ElementName=FirstNameInput}"/>
    									<Input:Argument Value="{Binding Text, ElementName=SurnameInput}"/>
    								</Input:InvokeMethod.Arguments>
    							</Input:InvokeMethod>
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</Button>
            <!--
                In this example the buttons content is derived from the method name, "ShowCurrentDetails" is formated as "Show Current Details"
            -->
    				<Button x:Name="FormatedNameExample" Margin="6" Input:Invoke.Target="{Binding DataContext, ElementName=StackPanel}">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<Input:InvokeMethod MethodName="ShowCurrentDetails" FeedbackPresenter="{StaticResource FeedbackPresenter}" >
    								<Input:InvokeMethod.Arguments>
    									<Input:Argument Value="{Binding SelectedItem, ElementName=PeopleList}" />                                
    								</Input:InvokeMethod.Arguments>
    							</Input:InvokeMethod>
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</Button>

    				<Button x:Name="PerformLongRunningAction" Margin="6" Input:Invoke.Target="{Binding DataContext, ElementName=StackPanel}">
    					<i:Interaction.Triggers>
    						<i:EventTrigger EventName="Click">
    							<Input:InvokeMethod MethodName="PerformLongRunningAction" FeedbackPresenter="{StaticResource FeedbackPresenter}" />
    						</i:EventTrigger>
    					</i:Interaction.Triggers>
    				</Button>
                    <TextBox>
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="KeyDown">
                                <Input:InvokeMethod MethodName="SendKeys" FeedbackPresenter="{x:Null}" >
                                    <Input:Argument Value="$eventArgs.Key"></Input:Argument>
                                </Input:InvokeMethod>                                
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </TextBox>
    				<ProgressBar DataContext="{Binding DataContext, ElementName=StackPanel}" Height="32" Margin="8,0" Value="{Binding LongRunningTaskProgress}"/>
    				<Grid Background="#FFE5E5E5" Height="39"/>
                    <Button Content="ClickMe" Click="ClickMe" />
    			</StackPanel>
    		</sdk:TabItem>
    		<sdk:TabItem x:Name="Sample2Tab" Header="Sample 2">
    			<Grid Background="#FFE5E5E5"/>
    		</sdk:TabItem>
    	</sdk:TabControl>
    </Grid>
</UserControl>
